{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "25f0fb6d-cfee-4e0d-9888-ddd5fa7a286f",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pl_bolts/models/self_supervised/amdim/amdim_module.py:34: UnderReviewWarning: The feature generate_power_seq is currently marked under review. The compatibility with other Lightning projects is not guaranteed and API may change at any time. The API and functionality may change without warning in future releases. More details: https://lightning-bolts.readthedocs.io/en/latest/stability.html\n",
      "  \"lr_options\": generate_power_seq(LEARNING_RATE_CIFAR, 11),\n",
      "/dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pl_bolts/models/self_supervised/amdim/amdim_module.py:92: UnderReviewWarning: The feature FeatureMapContrastiveTask is currently marked under review. The compatibility with other Lightning projects is not guaranteed and API may change at any time. The API and functionality may change without warning in future releases. More details: https://lightning-bolts.readthedocs.io/en/latest/stability.html\n",
      "  contrastive_task: Union[FeatureMapContrastiveTask] = FeatureMapContrastiveTask(\"01, 02, 11\"),\n",
      "/dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pl_bolts/losses/self_supervised_learning.py:228: UnderReviewWarning: The feature AmdimNCELoss is currently marked under review. The compatibility with other Lightning projects is not guaranteed and API may change at any time. The API and functionality may change without warning in future releases. More details: https://lightning-bolts.readthedocs.io/en/latest/stability.html\n",
      "  self.nce_loss = AmdimNCELoss(tclip)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=============USE cuda===========ZhaochangYang/HIPT/3-Self-Supervised-Eval/patch_extraction_utils.py\n",
      "Extracting Features for 'crc100knonorm' via 'beit_90'\n",
      "Loads checkpoint by local backend from path: /dssg/home/acct-medftn/medftn/BEPT/Model/mmselfsup/TCGA_Checkpoints/epoch_90.pth\n",
      "The model and loaded state dict do not match exactly\n",
      "\n",
      "unexpected key in source state_dict: neck.patch_aggregation.0.gamma_1, neck.patch_aggregation.0.gamma_2, neck.patch_aggregation.0.ln1.weight, neck.patch_aggregation.0.ln1.bias, neck.patch_aggregation.0.attn.q_bias, neck.patch_aggregation.0.attn.v_bias, neck.patch_aggregation.0.attn.qkv.weight, neck.patch_aggregation.0.attn.proj.weight, neck.patch_aggregation.0.attn.proj.bias, neck.patch_aggregation.0.ln2.weight, neck.patch_aggregation.0.ln2.bias, neck.patch_aggregation.0.ffn.layers.0.0.weight, neck.patch_aggregation.0.ffn.layers.0.0.bias, neck.patch_aggregation.0.ffn.layers.1.weight, neck.patch_aggregation.0.ffn.layers.1.bias, neck.patch_aggregation.1.gamma_1, neck.patch_aggregation.1.gamma_2, neck.patch_aggregation.1.ln1.weight, neck.patch_aggregation.1.ln1.bias, neck.patch_aggregation.1.attn.q_bias, neck.patch_aggregation.1.attn.v_bias, neck.patch_aggregation.1.attn.qkv.weight, neck.patch_aggregation.1.attn.proj.weight, neck.patch_aggregation.1.attn.proj.bias, neck.patch_aggregation.1.ln2.weight, neck.patch_aggregation.1.ln2.bias, neck.patch_aggregation.1.ffn.layers.0.0.weight, neck.patch_aggregation.1.ffn.layers.0.0.bias, neck.patch_aggregation.1.ffn.layers.1.weight, neck.patch_aggregation.1.ffn.layers.1.bias, neck.norm.weight, neck.norm.bias, target_generator.encoder.cls_token, target_generator.encoder.pos_embed, target_generator.encoder.patch_embed.projection.weight, target_generator.encoder.patch_embed.projection.bias, target_generator.encoder.layers.0.ln1.weight, target_generator.encoder.layers.0.ln1.bias, target_generator.encoder.layers.0.attn.q_bias, target_generator.encoder.layers.0.attn.v_bias, target_generator.encoder.layers.0.attn.qkv.weight, target_generator.encoder.layers.0.attn.proj.weight, target_generator.encoder.layers.0.attn.proj.bias, target_generator.encoder.layers.0.ln2.weight, target_generator.encoder.layers.0.ln2.bias, target_generator.encoder.layers.0.ffn.layers.0.0.weight, target_generator.encoder.layers.0.ffn.layers.0.0.bias, target_generator.encoder.layers.0.ffn.layers.1.weight, target_generator.encoder.layers.0.ffn.layers.1.bias, target_generator.encoder.layers.1.ln1.weight, target_generator.encoder.layers.1.ln1.bias, target_generator.encoder.layers.1.attn.q_bias, target_generator.encoder.layers.1.attn.v_bias, target_generator.encoder.layers.1.attn.qkv.weight, target_generator.encoder.layers.1.attn.proj.weight, target_generator.encoder.layers.1.attn.proj.bias, target_generator.encoder.layers.1.ln2.weight, target_generator.encoder.layers.1.ln2.bias, target_generator.encoder.layers.1.ffn.layers.0.0.weight, target_generator.encoder.layers.1.ffn.layers.0.0.bias, target_generator.encoder.layers.1.ffn.layers.1.weight, target_generator.encoder.layers.1.ffn.layers.1.bias, target_generator.encoder.layers.2.ln1.weight, target_generator.encoder.layers.2.ln1.bias, target_generator.encoder.layers.2.attn.q_bias, target_generator.encoder.layers.2.attn.v_bias, target_generator.encoder.layers.2.attn.qkv.weight, target_generator.encoder.layers.2.attn.proj.weight, target_generator.encoder.layers.2.attn.proj.bias, target_generator.encoder.layers.2.ln2.weight, target_generator.encoder.layers.2.ln2.bias, target_generator.encoder.layers.2.ffn.layers.0.0.weight, target_generator.encoder.layers.2.ffn.layers.0.0.bias, target_generator.encoder.layers.2.ffn.layers.1.weight, target_generator.encoder.layers.2.ffn.layers.1.bias, target_generator.encoder.layers.3.ln1.weight, target_generator.encoder.layers.3.ln1.bias, target_generator.encoder.layers.3.attn.q_bias, target_generator.encoder.layers.3.attn.v_bias, target_generator.encoder.layers.3.attn.qkv.weight, target_generator.encoder.layers.3.attn.proj.weight, target_generator.encoder.layers.3.attn.proj.bias, target_generator.encoder.layers.3.ln2.weight, target_generator.encoder.layers.3.ln2.bias, target_generator.encoder.layers.3.ffn.layers.0.0.weight, target_generator.encoder.layers.3.ffn.layers.0.0.bias, target_generator.encoder.layers.3.ffn.layers.1.weight, target_generator.encoder.layers.3.ffn.layers.1.bias, target_generator.encoder.layers.4.ln1.weight, target_generator.encoder.layers.4.ln1.bias, target_generator.encoder.layers.4.attn.q_bias, target_generator.encoder.layers.4.attn.v_bias, target_generator.encoder.layers.4.attn.qkv.weight, target_generator.encoder.layers.4.attn.proj.weight, target_generator.encoder.layers.4.attn.proj.bias, target_generator.encoder.layers.4.ln2.weight, target_generator.encoder.layers.4.ln2.bias, target_generator.encoder.layers.4.ffn.layers.0.0.weight, target_generator.encoder.layers.4.ffn.layers.0.0.bias, target_generator.encoder.layers.4.ffn.layers.1.weight, target_generator.encoder.layers.4.ffn.layers.1.bias, target_generator.encoder.layers.5.ln1.weight, target_generator.encoder.layers.5.ln1.bias, target_generator.encoder.layers.5.attn.q_bias, target_generator.encoder.layers.5.attn.v_bias, target_generator.encoder.layers.5.attn.qkv.weight, target_generator.encoder.layers.5.attn.proj.weight, target_generator.encoder.layers.5.attn.proj.bias, target_generator.encoder.layers.5.ln2.weight, target_generator.encoder.layers.5.ln2.bias, target_generator.encoder.layers.5.ffn.layers.0.0.weight, target_generator.encoder.layers.5.ffn.layers.0.0.bias, target_generator.encoder.layers.5.ffn.layers.1.weight, target_generator.encoder.layers.5.ffn.layers.1.bias, target_generator.encoder.layers.6.ln1.weight, target_generator.encoder.layers.6.ln1.bias, target_generator.encoder.layers.6.attn.q_bias, target_generator.encoder.layers.6.attn.v_bias, target_generator.encoder.layers.6.attn.qkv.weight, target_generator.encoder.layers.6.attn.proj.weight, target_generator.encoder.layers.6.attn.proj.bias, target_generator.encoder.layers.6.ln2.weight, target_generator.encoder.layers.6.ln2.bias, target_generator.encoder.layers.6.ffn.layers.0.0.weight, target_generator.encoder.layers.6.ffn.layers.0.0.bias, target_generator.encoder.layers.6.ffn.layers.1.weight, target_generator.encoder.layers.6.ffn.layers.1.bias, target_generator.encoder.layers.7.ln1.weight, target_generator.encoder.layers.7.ln1.bias, target_generator.encoder.layers.7.attn.q_bias, target_generator.encoder.layers.7.attn.v_bias, target_generator.encoder.layers.7.attn.qkv.weight, target_generator.encoder.layers.7.attn.proj.weight, target_generator.encoder.layers.7.attn.proj.bias, target_generator.encoder.layers.7.ln2.weight, target_generator.encoder.layers.7.ln2.bias, target_generator.encoder.layers.7.ffn.layers.0.0.weight, target_generator.encoder.layers.7.ffn.layers.0.0.bias, target_generator.encoder.layers.7.ffn.layers.1.weight, target_generator.encoder.layers.7.ffn.layers.1.bias, target_generator.encoder.layers.8.ln1.weight, target_generator.encoder.layers.8.ln1.bias, target_generator.encoder.layers.8.attn.q_bias, target_generator.encoder.layers.8.attn.v_bias, target_generator.encoder.layers.8.attn.qkv.weight, target_generator.encoder.layers.8.attn.proj.weight, target_generator.encoder.layers.8.attn.proj.bias, target_generator.encoder.layers.8.ln2.weight, target_generator.encoder.layers.8.ln2.bias, target_generator.encoder.layers.8.ffn.layers.0.0.weight, target_generator.encoder.layers.8.ffn.layers.0.0.bias, target_generator.encoder.layers.8.ffn.layers.1.weight, target_generator.encoder.layers.8.ffn.layers.1.bias, target_generator.encoder.layers.9.ln1.weight, target_generator.encoder.layers.9.ln1.bias, target_generator.encoder.layers.9.attn.q_bias, target_generator.encoder.layers.9.attn.v_bias, target_generator.encoder.layers.9.attn.qkv.weight, target_generator.encoder.layers.9.attn.proj.weight, target_generator.encoder.layers.9.attn.proj.bias, target_generator.encoder.layers.9.ln2.weight, target_generator.encoder.layers.9.ln2.bias, target_generator.encoder.layers.9.ffn.layers.0.0.weight, target_generator.encoder.layers.9.ffn.layers.0.0.bias, target_generator.encoder.layers.9.ffn.layers.1.weight, target_generator.encoder.layers.9.ffn.layers.1.bias, target_generator.encoder.layers.10.ln1.weight, target_generator.encoder.layers.10.ln1.bias, target_generator.encoder.layers.10.attn.q_bias, target_generator.encoder.layers.10.attn.v_bias, target_generator.encoder.layers.10.attn.qkv.weight, target_generator.encoder.layers.10.attn.proj.weight, target_generator.encoder.layers.10.attn.proj.bias, target_generator.encoder.layers.10.ln2.weight, target_generator.encoder.layers.10.ln2.bias, target_generator.encoder.layers.10.ffn.layers.0.0.weight, target_generator.encoder.layers.10.ffn.layers.0.0.bias, target_generator.encoder.layers.10.ffn.layers.1.weight, target_generator.encoder.layers.10.ffn.layers.1.bias, target_generator.encoder.layers.11.ln1.weight, target_generator.encoder.layers.11.ln1.bias, target_generator.encoder.layers.11.attn.q_bias, target_generator.encoder.layers.11.attn.v_bias, target_generator.encoder.layers.11.attn.qkv.weight, target_generator.encoder.layers.11.attn.proj.weight, target_generator.encoder.layers.11.attn.proj.bias, target_generator.encoder.layers.11.ln2.weight, target_generator.encoder.layers.11.ln2.bias, target_generator.encoder.layers.11.ffn.layers.0.0.weight, target_generator.encoder.layers.11.ffn.layers.0.0.bias, target_generator.encoder.layers.11.ffn.layers.1.weight, target_generator.encoder.layers.11.ffn.layers.1.bias, target_generator.encoder.ln1.weight, target_generator.encoder.ln1.bias, target_generator.quantize.cluster_size, target_generator.quantize.embedding.weight, target_generator.quantize.embedding.initted, target_generator.encode_task_layer.0.weight, target_generator.encode_task_layer.0.bias, target_generator.encode_task_layer.2.weight, target_generator.encode_task_layer.2.bias, backbone.mask_token, backbone.rel_pos_bias.relative_position_bias_table, backbone.rel_pos_bias.relative_position_index, head.cls_head.weight, head.cls_head.bias\n",
      "\n",
      "missing keys in source state_dict: backbone.layers.0.attn.relative_position_bias_table, backbone.layers.0.attn.relative_position_index, backbone.layers.1.attn.relative_position_bias_table, backbone.layers.1.attn.relative_position_index, backbone.layers.2.attn.relative_position_bias_table, backbone.layers.2.attn.relative_position_index, backbone.layers.3.attn.relative_position_bias_table, backbone.layers.3.attn.relative_position_index, backbone.layers.4.attn.relative_position_bias_table, backbone.layers.4.attn.relative_position_index, backbone.layers.5.attn.relative_position_bias_table, backbone.layers.5.attn.relative_position_index, backbone.layers.6.attn.relative_position_bias_table, backbone.layers.6.attn.relative_position_index, backbone.layers.7.attn.relative_position_bias_table, backbone.layers.7.attn.relative_position_index, backbone.layers.8.attn.relative_position_bias_table, backbone.layers.8.attn.relative_position_index, backbone.layers.9.attn.relative_position_bias_table, backbone.layers.9.attn.relative_position_index, backbone.layers.10.attn.relative_position_bias_table, backbone.layers.10.attn.relative_position_index, backbone.layers.11.attn.relative_position_bias_table, backbone.layers.11.attn.relative_position_index, backbone.ln2.weight, backbone.ln2.bias, head.fc.weight, head.fc.bias\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 10000/10000 [07:48<00:00, 21.34it/s]\n",
      "100%|██████████| 7180/7180 [01:16<00:00, 94.26it/s] \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting Features for 'crc100k' via 'beit_90'\n",
      "Loads checkpoint by local backend from path: /dssg/home/acct-medftn/medftn/BEPT/Model/mmselfsup/TCGA_Checkpoints/epoch_90.pth\n",
      "The model and loaded state dict do not match exactly\n",
      "\n",
      "unexpected key in source state_dict: neck.patch_aggregation.0.gamma_1, neck.patch_aggregation.0.gamma_2, neck.patch_aggregation.0.ln1.weight, neck.patch_aggregation.0.ln1.bias, neck.patch_aggregation.0.attn.q_bias, neck.patch_aggregation.0.attn.v_bias, neck.patch_aggregation.0.attn.qkv.weight, neck.patch_aggregation.0.attn.proj.weight, neck.patch_aggregation.0.attn.proj.bias, neck.patch_aggregation.0.ln2.weight, neck.patch_aggregation.0.ln2.bias, neck.patch_aggregation.0.ffn.layers.0.0.weight, neck.patch_aggregation.0.ffn.layers.0.0.bias, neck.patch_aggregation.0.ffn.layers.1.weight, neck.patch_aggregation.0.ffn.layers.1.bias, neck.patch_aggregation.1.gamma_1, neck.patch_aggregation.1.gamma_2, neck.patch_aggregation.1.ln1.weight, neck.patch_aggregation.1.ln1.bias, neck.patch_aggregation.1.attn.q_bias, neck.patch_aggregation.1.attn.v_bias, neck.patch_aggregation.1.attn.qkv.weight, neck.patch_aggregation.1.attn.proj.weight, neck.patch_aggregation.1.attn.proj.bias, neck.patch_aggregation.1.ln2.weight, neck.patch_aggregation.1.ln2.bias, neck.patch_aggregation.1.ffn.layers.0.0.weight, neck.patch_aggregation.1.ffn.layers.0.0.bias, neck.patch_aggregation.1.ffn.layers.1.weight, neck.patch_aggregation.1.ffn.layers.1.bias, neck.norm.weight, neck.norm.bias, target_generator.encoder.cls_token, target_generator.encoder.pos_embed, target_generator.encoder.patch_embed.projection.weight, target_generator.encoder.patch_embed.projection.bias, target_generator.encoder.layers.0.ln1.weight, target_generator.encoder.layers.0.ln1.bias, target_generator.encoder.layers.0.attn.q_bias, target_generator.encoder.layers.0.attn.v_bias, target_generator.encoder.layers.0.attn.qkv.weight, target_generator.encoder.layers.0.attn.proj.weight, target_generator.encoder.layers.0.attn.proj.bias, target_generator.encoder.layers.0.ln2.weight, target_generator.encoder.layers.0.ln2.bias, target_generator.encoder.layers.0.ffn.layers.0.0.weight, target_generator.encoder.layers.0.ffn.layers.0.0.bias, target_generator.encoder.layers.0.ffn.layers.1.weight, target_generator.encoder.layers.0.ffn.layers.1.bias, target_generator.encoder.layers.1.ln1.weight, target_generator.encoder.layers.1.ln1.bias, target_generator.encoder.layers.1.attn.q_bias, target_generator.encoder.layers.1.attn.v_bias, target_generator.encoder.layers.1.attn.qkv.weight, target_generator.encoder.layers.1.attn.proj.weight, target_generator.encoder.layers.1.attn.proj.bias, target_generator.encoder.layers.1.ln2.weight, target_generator.encoder.layers.1.ln2.bias, target_generator.encoder.layers.1.ffn.layers.0.0.weight, target_generator.encoder.layers.1.ffn.layers.0.0.bias, target_generator.encoder.layers.1.ffn.layers.1.weight, target_generator.encoder.layers.1.ffn.layers.1.bias, target_generator.encoder.layers.2.ln1.weight, target_generator.encoder.layers.2.ln1.bias, target_generator.encoder.layers.2.attn.q_bias, target_generator.encoder.layers.2.attn.v_bias, target_generator.encoder.layers.2.attn.qkv.weight, target_generator.encoder.layers.2.attn.proj.weight, target_generator.encoder.layers.2.attn.proj.bias, target_generator.encoder.layers.2.ln2.weight, target_generator.encoder.layers.2.ln2.bias, target_generator.encoder.layers.2.ffn.layers.0.0.weight, target_generator.encoder.layers.2.ffn.layers.0.0.bias, target_generator.encoder.layers.2.ffn.layers.1.weight, target_generator.encoder.layers.2.ffn.layers.1.bias, target_generator.encoder.layers.3.ln1.weight, target_generator.encoder.layers.3.ln1.bias, target_generator.encoder.layers.3.attn.q_bias, target_generator.encoder.layers.3.attn.v_bias, target_generator.encoder.layers.3.attn.qkv.weight, target_generator.encoder.layers.3.attn.proj.weight, target_generator.encoder.layers.3.attn.proj.bias, target_generator.encoder.layers.3.ln2.weight, target_generator.encoder.layers.3.ln2.bias, target_generator.encoder.layers.3.ffn.layers.0.0.weight, target_generator.encoder.layers.3.ffn.layers.0.0.bias, target_generator.encoder.layers.3.ffn.layers.1.weight, target_generator.encoder.layers.3.ffn.layers.1.bias, target_generator.encoder.layers.4.ln1.weight, target_generator.encoder.layers.4.ln1.bias, target_generator.encoder.layers.4.attn.q_bias, target_generator.encoder.layers.4.attn.v_bias, target_generator.encoder.layers.4.attn.qkv.weight, target_generator.encoder.layers.4.attn.proj.weight, target_generator.encoder.layers.4.attn.proj.bias, target_generator.encoder.layers.4.ln2.weight, target_generator.encoder.layers.4.ln2.bias, target_generator.encoder.layers.4.ffn.layers.0.0.weight, target_generator.encoder.layers.4.ffn.layers.0.0.bias, target_generator.encoder.layers.4.ffn.layers.1.weight, target_generator.encoder.layers.4.ffn.layers.1.bias, target_generator.encoder.layers.5.ln1.weight, target_generator.encoder.layers.5.ln1.bias, target_generator.encoder.layers.5.attn.q_bias, target_generator.encoder.layers.5.attn.v_bias, target_generator.encoder.layers.5.attn.qkv.weight, target_generator.encoder.layers.5.attn.proj.weight, target_generator.encoder.layers.5.attn.proj.bias, target_generator.encoder.layers.5.ln2.weight, target_generator.encoder.layers.5.ln2.bias, target_generator.encoder.layers.5.ffn.layers.0.0.weight, target_generator.encoder.layers.5.ffn.layers.0.0.bias, target_generator.encoder.layers.5.ffn.layers.1.weight, target_generator.encoder.layers.5.ffn.layers.1.bias, target_generator.encoder.layers.6.ln1.weight, target_generator.encoder.layers.6.ln1.bias, target_generator.encoder.layers.6.attn.q_bias, target_generator.encoder.layers.6.attn.v_bias, target_generator.encoder.layers.6.attn.qkv.weight, target_generator.encoder.layers.6.attn.proj.weight, target_generator.encoder.layers.6.attn.proj.bias, target_generator.encoder.layers.6.ln2.weight, target_generator.encoder.layers.6.ln2.bias, target_generator.encoder.layers.6.ffn.layers.0.0.weight, target_generator.encoder.layers.6.ffn.layers.0.0.bias, target_generator.encoder.layers.6.ffn.layers.1.weight, target_generator.encoder.layers.6.ffn.layers.1.bias, target_generator.encoder.layers.7.ln1.weight, target_generator.encoder.layers.7.ln1.bias, target_generator.encoder.layers.7.attn.q_bias, target_generator.encoder.layers.7.attn.v_bias, target_generator.encoder.layers.7.attn.qkv.weight, target_generator.encoder.layers.7.attn.proj.weight, target_generator.encoder.layers.7.attn.proj.bias, target_generator.encoder.layers.7.ln2.weight, target_generator.encoder.layers.7.ln2.bias, target_generator.encoder.layers.7.ffn.layers.0.0.weight, target_generator.encoder.layers.7.ffn.layers.0.0.bias, target_generator.encoder.layers.7.ffn.layers.1.weight, target_generator.encoder.layers.7.ffn.layers.1.bias, target_generator.encoder.layers.8.ln1.weight, target_generator.encoder.layers.8.ln1.bias, target_generator.encoder.layers.8.attn.q_bias, target_generator.encoder.layers.8.attn.v_bias, target_generator.encoder.layers.8.attn.qkv.weight, target_generator.encoder.layers.8.attn.proj.weight, target_generator.encoder.layers.8.attn.proj.bias, target_generator.encoder.layers.8.ln2.weight, target_generator.encoder.layers.8.ln2.bias, target_generator.encoder.layers.8.ffn.layers.0.0.weight, target_generator.encoder.layers.8.ffn.layers.0.0.bias, target_generator.encoder.layers.8.ffn.layers.1.weight, target_generator.encoder.layers.8.ffn.layers.1.bias, target_generator.encoder.layers.9.ln1.weight, target_generator.encoder.layers.9.ln1.bias, target_generator.encoder.layers.9.attn.q_bias, target_generator.encoder.layers.9.attn.v_bias, target_generator.encoder.layers.9.attn.qkv.weight, target_generator.encoder.layers.9.attn.proj.weight, target_generator.encoder.layers.9.attn.proj.bias, target_generator.encoder.layers.9.ln2.weight, target_generator.encoder.layers.9.ln2.bias, target_generator.encoder.layers.9.ffn.layers.0.0.weight, target_generator.encoder.layers.9.ffn.layers.0.0.bias, target_generator.encoder.layers.9.ffn.layers.1.weight, target_generator.encoder.layers.9.ffn.layers.1.bias, target_generator.encoder.layers.10.ln1.weight, target_generator.encoder.layers.10.ln1.bias, target_generator.encoder.layers.10.attn.q_bias, target_generator.encoder.layers.10.attn.v_bias, target_generator.encoder.layers.10.attn.qkv.weight, target_generator.encoder.layers.10.attn.proj.weight, target_generator.encoder.layers.10.attn.proj.bias, target_generator.encoder.layers.10.ln2.weight, target_generator.encoder.layers.10.ln2.bias, target_generator.encoder.layers.10.ffn.layers.0.0.weight, target_generator.encoder.layers.10.ffn.layers.0.0.bias, target_generator.encoder.layers.10.ffn.layers.1.weight, target_generator.encoder.layers.10.ffn.layers.1.bias, target_generator.encoder.layers.11.ln1.weight, target_generator.encoder.layers.11.ln1.bias, target_generator.encoder.layers.11.attn.q_bias, target_generator.encoder.layers.11.attn.v_bias, target_generator.encoder.layers.11.attn.qkv.weight, target_generator.encoder.layers.11.attn.proj.weight, target_generator.encoder.layers.11.attn.proj.bias, target_generator.encoder.layers.11.ln2.weight, target_generator.encoder.layers.11.ln2.bias, target_generator.encoder.layers.11.ffn.layers.0.0.weight, target_generator.encoder.layers.11.ffn.layers.0.0.bias, target_generator.encoder.layers.11.ffn.layers.1.weight, target_generator.encoder.layers.11.ffn.layers.1.bias, target_generator.encoder.ln1.weight, target_generator.encoder.ln1.bias, target_generator.quantize.cluster_size, target_generator.quantize.embedding.weight, target_generator.quantize.embedding.initted, target_generator.encode_task_layer.0.weight, target_generator.encode_task_layer.0.bias, target_generator.encode_task_layer.2.weight, target_generator.encode_task_layer.2.bias, backbone.mask_token, backbone.rel_pos_bias.relative_position_bias_table, backbone.rel_pos_bias.relative_position_index, head.cls_head.weight, head.cls_head.bias\n",
      "\n",
      "missing keys in source state_dict: backbone.layers.0.attn.relative_position_bias_table, backbone.layers.0.attn.relative_position_index, backbone.layers.1.attn.relative_position_bias_table, backbone.layers.1.attn.relative_position_index, backbone.layers.2.attn.relative_position_bias_table, backbone.layers.2.attn.relative_position_index, backbone.layers.3.attn.relative_position_bias_table, backbone.layers.3.attn.relative_position_index, backbone.layers.4.attn.relative_position_bias_table, backbone.layers.4.attn.relative_position_index, backbone.layers.5.attn.relative_position_bias_table, backbone.layers.5.attn.relative_position_index, backbone.layers.6.attn.relative_position_bias_table, backbone.layers.6.attn.relative_position_index, backbone.layers.7.attn.relative_position_bias_table, backbone.layers.7.attn.relative_position_index, backbone.layers.8.attn.relative_position_bias_table, backbone.layers.8.attn.relative_position_index, backbone.layers.9.attn.relative_position_bias_table, backbone.layers.9.attn.relative_position_index, backbone.layers.10.attn.relative_position_bias_table, backbone.layers.10.attn.relative_position_index, backbone.layers.11.attn.relative_position_bias_table, backbone.layers.11.attn.relative_position_index, backbone.ln2.weight, backbone.ln2.bias, head.fc.weight, head.fc.bias\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 10000/10000 [08:57<00:00, 18.61it/s] \n",
      "100%|██████████| 7180/7180 [01:12<00:00, 98.37it/s] \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracting Features for 'bcss' via 'beit_90'\n",
      "Loads checkpoint by local backend from path: /dssg/home/acct-medftn/medftn/BEPT/Model/mmselfsup/TCGA_Checkpoints/epoch_90.pth\n",
      "The model and loaded state dict do not match exactly\n",
      "\n",
      "unexpected key in source state_dict: neck.patch_aggregation.0.gamma_1, neck.patch_aggregation.0.gamma_2, neck.patch_aggregation.0.ln1.weight, neck.patch_aggregation.0.ln1.bias, neck.patch_aggregation.0.attn.q_bias, neck.patch_aggregation.0.attn.v_bias, neck.patch_aggregation.0.attn.qkv.weight, neck.patch_aggregation.0.attn.proj.weight, neck.patch_aggregation.0.attn.proj.bias, neck.patch_aggregation.0.ln2.weight, neck.patch_aggregation.0.ln2.bias, neck.patch_aggregation.0.ffn.layers.0.0.weight, neck.patch_aggregation.0.ffn.layers.0.0.bias, neck.patch_aggregation.0.ffn.layers.1.weight, neck.patch_aggregation.0.ffn.layers.1.bias, neck.patch_aggregation.1.gamma_1, neck.patch_aggregation.1.gamma_2, neck.patch_aggregation.1.ln1.weight, neck.patch_aggregation.1.ln1.bias, neck.patch_aggregation.1.attn.q_bias, neck.patch_aggregation.1.attn.v_bias, neck.patch_aggregation.1.attn.qkv.weight, neck.patch_aggregation.1.attn.proj.weight, neck.patch_aggregation.1.attn.proj.bias, neck.patch_aggregation.1.ln2.weight, neck.patch_aggregation.1.ln2.bias, neck.patch_aggregation.1.ffn.layers.0.0.weight, neck.patch_aggregation.1.ffn.layers.0.0.bias, neck.patch_aggregation.1.ffn.layers.1.weight, neck.patch_aggregation.1.ffn.layers.1.bias, neck.norm.weight, neck.norm.bias, target_generator.encoder.cls_token, target_generator.encoder.pos_embed, target_generator.encoder.patch_embed.projection.weight, target_generator.encoder.patch_embed.projection.bias, target_generator.encoder.layers.0.ln1.weight, target_generator.encoder.layers.0.ln1.bias, target_generator.encoder.layers.0.attn.q_bias, target_generator.encoder.layers.0.attn.v_bias, target_generator.encoder.layers.0.attn.qkv.weight, target_generator.encoder.layers.0.attn.proj.weight, target_generator.encoder.layers.0.attn.proj.bias, target_generator.encoder.layers.0.ln2.weight, target_generator.encoder.layers.0.ln2.bias, target_generator.encoder.layers.0.ffn.layers.0.0.weight, target_generator.encoder.layers.0.ffn.layers.0.0.bias, target_generator.encoder.layers.0.ffn.layers.1.weight, target_generator.encoder.layers.0.ffn.layers.1.bias, target_generator.encoder.layers.1.ln1.weight, target_generator.encoder.layers.1.ln1.bias, target_generator.encoder.layers.1.attn.q_bias, target_generator.encoder.layers.1.attn.v_bias, target_generator.encoder.layers.1.attn.qkv.weight, target_generator.encoder.layers.1.attn.proj.weight, target_generator.encoder.layers.1.attn.proj.bias, target_generator.encoder.layers.1.ln2.weight, target_generator.encoder.layers.1.ln2.bias, target_generator.encoder.layers.1.ffn.layers.0.0.weight, target_generator.encoder.layers.1.ffn.layers.0.0.bias, target_generator.encoder.layers.1.ffn.layers.1.weight, target_generator.encoder.layers.1.ffn.layers.1.bias, target_generator.encoder.layers.2.ln1.weight, target_generator.encoder.layers.2.ln1.bias, target_generator.encoder.layers.2.attn.q_bias, target_generator.encoder.layers.2.attn.v_bias, target_generator.encoder.layers.2.attn.qkv.weight, target_generator.encoder.layers.2.attn.proj.weight, target_generator.encoder.layers.2.attn.proj.bias, target_generator.encoder.layers.2.ln2.weight, target_generator.encoder.layers.2.ln2.bias, target_generator.encoder.layers.2.ffn.layers.0.0.weight, target_generator.encoder.layers.2.ffn.layers.0.0.bias, target_generator.encoder.layers.2.ffn.layers.1.weight, target_generator.encoder.layers.2.ffn.layers.1.bias, target_generator.encoder.layers.3.ln1.weight, target_generator.encoder.layers.3.ln1.bias, target_generator.encoder.layers.3.attn.q_bias, target_generator.encoder.layers.3.attn.v_bias, target_generator.encoder.layers.3.attn.qkv.weight, target_generator.encoder.layers.3.attn.proj.weight, target_generator.encoder.layers.3.attn.proj.bias, target_generator.encoder.layers.3.ln2.weight, target_generator.encoder.layers.3.ln2.bias, target_generator.encoder.layers.3.ffn.layers.0.0.weight, target_generator.encoder.layers.3.ffn.layers.0.0.bias, target_generator.encoder.layers.3.ffn.layers.1.weight, target_generator.encoder.layers.3.ffn.layers.1.bias, target_generator.encoder.layers.4.ln1.weight, target_generator.encoder.layers.4.ln1.bias, target_generator.encoder.layers.4.attn.q_bias, target_generator.encoder.layers.4.attn.v_bias, target_generator.encoder.layers.4.attn.qkv.weight, target_generator.encoder.layers.4.attn.proj.weight, target_generator.encoder.layers.4.attn.proj.bias, target_generator.encoder.layers.4.ln2.weight, target_generator.encoder.layers.4.ln2.bias, target_generator.encoder.layers.4.ffn.layers.0.0.weight, target_generator.encoder.layers.4.ffn.layers.0.0.bias, target_generator.encoder.layers.4.ffn.layers.1.weight, target_generator.encoder.layers.4.ffn.layers.1.bias, target_generator.encoder.layers.5.ln1.weight, target_generator.encoder.layers.5.ln1.bias, target_generator.encoder.layers.5.attn.q_bias, target_generator.encoder.layers.5.attn.v_bias, target_generator.encoder.layers.5.attn.qkv.weight, target_generator.encoder.layers.5.attn.proj.weight, target_generator.encoder.layers.5.attn.proj.bias, target_generator.encoder.layers.5.ln2.weight, target_generator.encoder.layers.5.ln2.bias, target_generator.encoder.layers.5.ffn.layers.0.0.weight, target_generator.encoder.layers.5.ffn.layers.0.0.bias, target_generator.encoder.layers.5.ffn.layers.1.weight, target_generator.encoder.layers.5.ffn.layers.1.bias, target_generator.encoder.layers.6.ln1.weight, target_generator.encoder.layers.6.ln1.bias, target_generator.encoder.layers.6.attn.q_bias, target_generator.encoder.layers.6.attn.v_bias, target_generator.encoder.layers.6.attn.qkv.weight, target_generator.encoder.layers.6.attn.proj.weight, target_generator.encoder.layers.6.attn.proj.bias, target_generator.encoder.layers.6.ln2.weight, target_generator.encoder.layers.6.ln2.bias, target_generator.encoder.layers.6.ffn.layers.0.0.weight, target_generator.encoder.layers.6.ffn.layers.0.0.bias, target_generator.encoder.layers.6.ffn.layers.1.weight, target_generator.encoder.layers.6.ffn.layers.1.bias, target_generator.encoder.layers.7.ln1.weight, target_generator.encoder.layers.7.ln1.bias, target_generator.encoder.layers.7.attn.q_bias, target_generator.encoder.layers.7.attn.v_bias, target_generator.encoder.layers.7.attn.qkv.weight, target_generator.encoder.layers.7.attn.proj.weight, target_generator.encoder.layers.7.attn.proj.bias, target_generator.encoder.layers.7.ln2.weight, target_generator.encoder.layers.7.ln2.bias, target_generator.encoder.layers.7.ffn.layers.0.0.weight, target_generator.encoder.layers.7.ffn.layers.0.0.bias, target_generator.encoder.layers.7.ffn.layers.1.weight, target_generator.encoder.layers.7.ffn.layers.1.bias, target_generator.encoder.layers.8.ln1.weight, target_generator.encoder.layers.8.ln1.bias, target_generator.encoder.layers.8.attn.q_bias, target_generator.encoder.layers.8.attn.v_bias, target_generator.encoder.layers.8.attn.qkv.weight, target_generator.encoder.layers.8.attn.proj.weight, target_generator.encoder.layers.8.attn.proj.bias, target_generator.encoder.layers.8.ln2.weight, target_generator.encoder.layers.8.ln2.bias, target_generator.encoder.layers.8.ffn.layers.0.0.weight, target_generator.encoder.layers.8.ffn.layers.0.0.bias, target_generator.encoder.layers.8.ffn.layers.1.weight, target_generator.encoder.layers.8.ffn.layers.1.bias, target_generator.encoder.layers.9.ln1.weight, target_generator.encoder.layers.9.ln1.bias, target_generator.encoder.layers.9.attn.q_bias, target_generator.encoder.layers.9.attn.v_bias, target_generator.encoder.layers.9.attn.qkv.weight, target_generator.encoder.layers.9.attn.proj.weight, target_generator.encoder.layers.9.attn.proj.bias, target_generator.encoder.layers.9.ln2.weight, target_generator.encoder.layers.9.ln2.bias, target_generator.encoder.layers.9.ffn.layers.0.0.weight, target_generator.encoder.layers.9.ffn.layers.0.0.bias, target_generator.encoder.layers.9.ffn.layers.1.weight, target_generator.encoder.layers.9.ffn.layers.1.bias, target_generator.encoder.layers.10.ln1.weight, target_generator.encoder.layers.10.ln1.bias, target_generator.encoder.layers.10.attn.q_bias, target_generator.encoder.layers.10.attn.v_bias, target_generator.encoder.layers.10.attn.qkv.weight, target_generator.encoder.layers.10.attn.proj.weight, target_generator.encoder.layers.10.attn.proj.bias, target_generator.encoder.layers.10.ln2.weight, target_generator.encoder.layers.10.ln2.bias, target_generator.encoder.layers.10.ffn.layers.0.0.weight, target_generator.encoder.layers.10.ffn.layers.0.0.bias, target_generator.encoder.layers.10.ffn.layers.1.weight, target_generator.encoder.layers.10.ffn.layers.1.bias, target_generator.encoder.layers.11.ln1.weight, target_generator.encoder.layers.11.ln1.bias, target_generator.encoder.layers.11.attn.q_bias, target_generator.encoder.layers.11.attn.v_bias, target_generator.encoder.layers.11.attn.qkv.weight, target_generator.encoder.layers.11.attn.proj.weight, target_generator.encoder.layers.11.attn.proj.bias, target_generator.encoder.layers.11.ln2.weight, target_generator.encoder.layers.11.ln2.bias, target_generator.encoder.layers.11.ffn.layers.0.0.weight, target_generator.encoder.layers.11.ffn.layers.0.0.bias, target_generator.encoder.layers.11.ffn.layers.1.weight, target_generator.encoder.layers.11.ffn.layers.1.bias, target_generator.encoder.ln1.weight, target_generator.encoder.ln1.bias, target_generator.quantize.cluster_size, target_generator.quantize.embedding.weight, target_generator.quantize.embedding.initted, target_generator.encode_task_layer.0.weight, target_generator.encode_task_layer.0.bias, target_generator.encode_task_layer.2.weight, target_generator.encode_task_layer.2.bias, backbone.mask_token, backbone.rel_pos_bias.relative_position_bias_table, backbone.rel_pos_bias.relative_position_index, head.cls_head.weight, head.cls_head.bias\n",
      "\n",
      "missing keys in source state_dict: backbone.layers.0.attn.relative_position_bias_table, backbone.layers.0.attn.relative_position_index, backbone.layers.1.attn.relative_position_bias_table, backbone.layers.1.attn.relative_position_index, backbone.layers.2.attn.relative_position_bias_table, backbone.layers.2.attn.relative_position_index, backbone.layers.3.attn.relative_position_bias_table, backbone.layers.3.attn.relative_position_index, backbone.layers.4.attn.relative_position_bias_table, backbone.layers.4.attn.relative_position_index, backbone.layers.5.attn.relative_position_bias_table, backbone.layers.5.attn.relative_position_index, backbone.layers.6.attn.relative_position_bias_table, backbone.layers.6.attn.relative_position_index, backbone.layers.7.attn.relative_position_bias_table, backbone.layers.7.attn.relative_position_index, backbone.layers.8.attn.relative_position_bias_table, backbone.layers.8.attn.relative_position_index, backbone.layers.9.attn.relative_position_bias_table, backbone.layers.9.attn.relative_position_index, backbone.layers.10.attn.relative_position_bias_table, backbone.layers.10.attn.relative_position_index, backbone.layers.11.attn.relative_position_bias_table, backbone.layers.11.attn.relative_position_index, backbone.ln2.weight, backbone.ln2.bias, head.fc.weight, head.fc.bias\n",
      "\n"
     ]
    },
    {
     "ename": "FileNotFoundError",
     "evalue": "[Errno 2] No such file or directory: './data/BCSS/40x/patches/summary.csv'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mFileNotFoundError\u001b[0m                         Traceback (most recent call last)",
      "File \u001b[0;32m~/BEPT/Model/benchMark/HIPT/3-Self-Supervised-Eval/patch_extraction.py:42\u001b[0m\n\u001b[1;32m     40\u001b[0m create_embeddings(patch_datasets\u001b[38;5;241m=\u001b[39mpatch_datasets, embeddings_dir\u001b[38;5;241m=\u001b[39mlibrary_path, enc_name\u001b[38;5;241m=\u001b[39menc_name, dataset\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcrc100knonorm\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m     41\u001b[0m create_embeddings(patch_datasets\u001b[38;5;241m=\u001b[39mpatch_datasets, embeddings_dir\u001b[38;5;241m=\u001b[39mlibrary_path, enc_name\u001b[38;5;241m=\u001b[39menc_name, dataset\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcrc100k\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m---> 42\u001b[0m \u001b[43mcreate_embeddings\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpatch_datasets\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpatch_datasets\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43membeddings_dir\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mlibrary_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43menc_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43menc_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdataset\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mbcss\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m     43\u001b[0m create_embeddings(patch_datasets\u001b[38;5;241m=\u001b[39mpatch_datasets, embeddings_dir\u001b[38;5;241m=\u001b[39mlibrary_path, enc_name\u001b[38;5;241m=\u001b[39menc_name, dataset\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbreastpathq\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
      "File \u001b[0;32m~/BEPT/Model/benchMark/HIPT/3-Self-Supervised-Eval/patch_extraction_utils.py:285\u001b[0m, in \u001b[0;36mcreate_embeddings\u001b[0;34m(embeddings_dir, enc_name, dataset, save_patches, sprite_dim, patch_datasets, assets_dir, disentangle, stage)\u001b[0m\n\u001b[1;32m    282\u001b[0m dataroot \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(patch_datasets, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mBCSS/40x/patches/All/\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m    283\u001b[0m csv_path \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(patch_datasets, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mBCSS/40x/patches/summary.csv\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m--> 285\u001b[0m dataset_csv \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_csv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcsv_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msep\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m \u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfilename,train\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mstr\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m'\u001b[39m, expand\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\u001b[38;5;241m.\u001b[39mastype(\u001b[38;5;28mint\u001b[39m)\n\u001b[1;32m    286\u001b[0m dataset_csv\u001b[38;5;241m.\u001b[39mcolumns \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlabel\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtrain\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m    287\u001b[0m dataset_csv \u001b[38;5;241m=\u001b[39m dataset_csv[dataset_csv[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlabel\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39misin([\u001b[38;5;241m0\u001b[39m,\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m,\u001b[38;5;241m3\u001b[39m])]\n",
      "File \u001b[0;32m~/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pandas/io/parsers/readers.py:948\u001b[0m, in \u001b[0;36mread_csv\u001b[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[0m\n\u001b[1;32m    935\u001b[0m kwds_defaults \u001b[38;5;241m=\u001b[39m _refine_defaults_read(\n\u001b[1;32m    936\u001b[0m     dialect,\n\u001b[1;32m    937\u001b[0m     delimiter,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    944\u001b[0m     dtype_backend\u001b[38;5;241m=\u001b[39mdtype_backend,\n\u001b[1;32m    945\u001b[0m )\n\u001b[1;32m    946\u001b[0m kwds\u001b[38;5;241m.\u001b[39mupdate(kwds_defaults)\n\u001b[0;32m--> 948\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pandas/io/parsers/readers.py:611\u001b[0m, in \u001b[0;36m_read\u001b[0;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[1;32m    608\u001b[0m _validate_names(kwds\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnames\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m))\n\u001b[1;32m    610\u001b[0m \u001b[38;5;66;03m# Create the parser.\u001b[39;00m\n\u001b[0;32m--> 611\u001b[0m parser \u001b[38;5;241m=\u001b[39m \u001b[43mTextFileReader\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    613\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m chunksize \u001b[38;5;129;01mor\u001b[39;00m iterator:\n\u001b[1;32m    614\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m parser\n",
      "File \u001b[0;32m~/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pandas/io/parsers/readers.py:1448\u001b[0m, in \u001b[0;36mTextFileReader.__init__\u001b[0;34m(self, f, engine, **kwds)\u001b[0m\n\u001b[1;32m   1445\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moptions[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhas_index_names\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m kwds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhas_index_names\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m   1447\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles: IOHandles \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m-> 1448\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engine \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_make_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mengine\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pandas/io/parsers/readers.py:1705\u001b[0m, in \u001b[0;36mTextFileReader._make_engine\u001b[0;34m(self, f, engine)\u001b[0m\n\u001b[1;32m   1703\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m mode:\n\u001b[1;32m   1704\u001b[0m         mode \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m-> 1705\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles \u001b[38;5;241m=\u001b[39m \u001b[43mget_handle\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m   1706\u001b[0m \u001b[43m    \u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1707\u001b[0m \u001b[43m    \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1708\u001b[0m \u001b[43m    \u001b[49m\u001b[43mencoding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mencoding\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1709\u001b[0m \u001b[43m    \u001b[49m\u001b[43mcompression\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcompression\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1710\u001b[0m \u001b[43m    \u001b[49m\u001b[43mmemory_map\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmemory_map\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1711\u001b[0m \u001b[43m    \u001b[49m\u001b[43mis_text\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mis_text\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1712\u001b[0m \u001b[43m    \u001b[49m\u001b[43merrors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mencoding_errors\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstrict\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1713\u001b[0m \u001b[43m    \u001b[49m\u001b[43mstorage_options\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstorage_options\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   1714\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   1715\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m   1716\u001b[0m f \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles\u001b[38;5;241m.\u001b[39mhandle\n",
      "File \u001b[0;32m~/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages/pandas/io/common.py:863\u001b[0m, in \u001b[0;36mget_handle\u001b[0;34m(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)\u001b[0m\n\u001b[1;32m    858\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(handle, \u001b[38;5;28mstr\u001b[39m):\n\u001b[1;32m    859\u001b[0m     \u001b[38;5;66;03m# Check whether the filename is to be opened in binary mode.\u001b[39;00m\n\u001b[1;32m    860\u001b[0m     \u001b[38;5;66;03m# Binary mode does not support 'encoding' and 'newline'.\u001b[39;00m\n\u001b[1;32m    861\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m ioargs\u001b[38;5;241m.\u001b[39mencoding \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m ioargs\u001b[38;5;241m.\u001b[39mmode:\n\u001b[1;32m    862\u001b[0m         \u001b[38;5;66;03m# Encoding\u001b[39;00m\n\u001b[0;32m--> 863\u001b[0m         handle \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[1;32m    864\u001b[0m \u001b[43m            \u001b[49m\u001b[43mhandle\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    865\u001b[0m \u001b[43m            \u001b[49m\u001b[43mioargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmode\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    866\u001b[0m \u001b[43m            \u001b[49m\u001b[43mencoding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mioargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencoding\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    867\u001b[0m \u001b[43m            \u001b[49m\u001b[43merrors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43merrors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    868\u001b[0m \u001b[43m            \u001b[49m\u001b[43mnewline\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m    869\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    870\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m    871\u001b[0m         \u001b[38;5;66;03m# Binary mode\u001b[39;00m\n\u001b[1;32m    872\u001b[0m         handle \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mopen\u001b[39m(handle, ioargs\u001b[38;5;241m.\u001b[39mmode)\n",
      "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: './data/BCSS/40x/patches/summary.csv'"
     ]
    }
   ],
   "source": [
    "%run patch_extraction.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "60934d6b-6ac0-4928-9167-cb5f8ab8f495",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Requirement already satisfied: pandas in /dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages (1.2.4)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Requirement already satisfied: pandas in /dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages (1.2.4)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Requirement already satisfied: python-dateutil&gt;=2.7.3 in /dssg/home/acct-medftn/medftn/.local/lib/python3.9/site-packages (from pandas) (2.8.2)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Requirement already satisfied: python-dateutil>=2.7.3 in /dssg/home/acct-medftn/medftn/.local/lib/python3.9/site-packages (from pandas) (2.8.2)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Requirement already satisfied: pytz&gt;=2017.3 in /dssg/home/acct-medftn/medftn/.local/lib/python3.9/site-packages (from pandas) (2023.3)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Requirement already satisfied: pytz>=2017.3 in /dssg/home/acct-medftn/medftn/.local/lib/python3.9/site-packages (from pandas) (2023.3)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Requirement already satisfied: numpy&gt;=1.16.5 in /dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages (from pandas) (1.21.5)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Requirement already satisfied: numpy>=1.16.5 in /dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages (from pandas) (1.21.5)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Requirement already satisfied: six&gt;=1.5 in /dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages (from python-dateutil&gt;=2.7.3-&gt;pandas) (1.16.0)\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Requirement already satisfied: six>=1.5 in /dssg/home/acct-medftn/medftn/.conda/envs/mmselfsup_yzc/lib/python3.9/site-packages (from python-dateutil>=2.7.3->pandas) (1.16.0)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%run -m  pip install pandas\n",
    "# matplotlib datashader bokeh holoviews scikit-image and colorcet to be installed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aac7b7eb-f242-42a2-8d83-2c355b704c4a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f4cbd467-205f-4bc5-9939-d4f9eadb4503",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mmselfsup_yzc",
   "language": "python",
   "name": "mmselfsup_yzc"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
